The only workaround I've seen for this involves calling debug_backtrace to determine the class name of the caller(s). This is of course a giant hack. I've seen some code that combines a backtrace with actually opening up the calling file and parsing it to figure things out.
Bizarre, horrible stuff The lack of LSB is going to come back and bite you later. Upgrade now, even if it means switching hosts. In fact, especially if it means switching hosts.5.3 has been out for a year now.
The only workaround I've seen for this involves calling debug_backtrace to determine the class name of the caller(s). This is of course a giant hack. I've seen some code that combines a backtrace with actually opening up the calling file and parsing it to figure things out.
Bizarre, horrible stuff. The lack of LSB is going to come back and bite you later. Upgrade now, even if it means switching hosts.In fact, especially if it means switching hosts.
5.3 has been out for a year now.
I did a test, and calling debug_backtrace() within the abstract create() property didn't have an element that referenced the originating class! I would think it would be there, but I guess this is why we need late static binding :P – user151841 Aug 13 '10 at 19:02 Check out m1tk4's code then, it might be smarter... – Charles Aug 13 '10 at 23:00.
Here's what I've been using until moving to 5.3: if (!function_exists('get_called_class')) { /** * Implementation of get_called_class() for pre-5.3 PHP * * @return string */ function get_called_class() { $bt = debug_backtrace(); $lines = file($bt1'file'); preg_match('/(a-zA-Z0-9\_+)::'. $bt1'function'. '/', $lines$bt1'line'-1, $matches); return $matches1; } } This lets you determine in a static function what class name the function has been invoked with.It's a workaround that has some performance issues but it's the only one I've found.
If there are others I'd be interested to know.
Once way to do it is to override the various instantiation methods, and pass the name of the class directly.
He's not using 5.3, so he doesn't have the __CLASS__ constant to begin with... – Charles Aug 13 '10 at 19:02 I'm the OP ;) __CLASS__ has been available since 4.3: php. Net/manual/en/language.constants.predefined. Php .
I'm using 5.2.6 and I use it all the time. – user151841 Aug 13 '10 at 19:18 I need to learn to read, heh. – Charles Aug 13 '10 at 23:00 I do the same thing all the time :) – user151841 Aug 14 '10 at 6:34.
M going to demonstrate how to take advantage of this capability by constructing an abstract factory class whose concrete implementations will be responsible for creating a few HTML widgets. Are you feeling eager to see how this will be done? Then don?
T hesitate; start reading!
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.